<?php
namespace App\Api\Appfc114;

use PhalApi\Api;
use PhalApi\Exception\BadRequestException;
use PhalApi\Request;
use App\Domain\Appfc114\News as DomainNews;


/**
 * 资讯接口服务
 *
 * @author: dogstar <chanzonghuang@gmail.com> 2014-10-04
 */

class News extends Api {

    /**
     * token对象
     */
    public $token;

    /**
     * 当前用户信息
     */
    public $user;

    public function __construct()
    {
        //允许所有域名发起的跨域请求
        header('Access-Control-Allow-Origin: *');  //支持全域名访问，不安全，部署后需要固定限制为客户端网址
        //header('Access-Control-Allow-Methods:POST,GET,OPTIONS,DELETE'); //支持的http 动作
        //header('Access-Control-Allow-Headers:Authorization,content-type');  //响应头 请按照自己需求添加。
        //$this->di = \PhalApi\DI();


    }

	public function getRules() {
        return array(
            'getList' => []
        );

	}

    /**
     * 返回资讯列表
     * @return obj 资讯信息
     */
    public function getList() {
        $data = array(
            '0'=>array('id'=>'975','title'=>'购房赎楼贷（尾款垫资）业务','type'=>'2',
                'intro'=>'抵押贷办理中，有结清原贷款需求和/或急需用款需求的客户',
                'photo'=>'/upload/esf/201937/7b2d4kru3r7cqe9hqrje396ss4_1568281184622_s.jpg',
                'linkurl'=>'https://mp.weixin.qq.com/s/WA3W0MI435P6ZDz1O_Vecg',
                'hits'=>'92','create_date_val'=>'2019-10-23','publisher'=>'成都要买房'),
            '1'=>array('id'=>'972','title'=>'购房赎楼贷（尾款垫资）业务','type'=>'1',
                'intro'=>'抵押贷办理中，有结清原贷款需求和/或急需用款需求的客户',
                'photo'=>'/upload/esf/201937/7b2d4kru3r7cqe9hqrje396ss4_1568281184622_s.jpg',
                'linkurl'=>'https://mp.weixin.qq.com/s/WA3W0MI435P6ZDz1O_Vecg',
                'hits'=>'92','create_date_val'=>'2019-10-23','publisher'=>'成都要买房')
        );
        error_log("getList!", 0);
        $News = new DomainNews();
        $data = $News->getlist();

        return $data;
    }

    /**
     * 获取资讯详情

     * @return array data 客户信息
     * @return int time 当前时间戳
     */
    public function Detail()
    {
        error_log("NewsDetail!", 0);
        //主表数据
        $params =  \PhalApi\DI()->request->getAll();
        //插入主表数据
        $domain = new DomainNews();
        $data = $domain->Detail($params["id"],1);

        return $data;

    }


}
